package com.hxht.storage.server.dao.impl;

import javax.annotation.PostConstruct;
import javax.persistence.Query;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;

import com.hxht.storage.server.dao.RecordMarkDao;
import com.hxht.storage.server.pojo.RecordMarkInfo;

@Repository
public class RecordMarkDaoImpl extends BaseDaoImpl<RecordMarkInfo>
		implements RecordMarkDao {

	@PostConstruct
	@Override
	public void init() {
		clazz = RecordMarkInfo.class;
	}

	@Override
	public void removeByUuid(String uuid) {
		Query query = entityManage.createQuery("delete from RecordMarkInfo where uuid=:uuid");
		
		query.setParameter("uuid", uuid);
		
		query.executeUpdate();
	}

	@Override
	public RecordMarkInfo getByUuid(String uuid) {

		RecordMarkInfo markInfo = null;
		
		TypedQuery<RecordMarkInfo> query = entityManage
				.createQuery("from RecordMarkInfo where uuid=:uuid", clazz);

		query.setParameter("uuid", uuid);
		
		markInfo = query.getSingleResult();
		
		return markInfo;
	}
	
}
